package com.tedu.login.service;


import com.tedu.login.mapper.LoginMapper;
import com.tedu.login.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginServiceImpl implements LoginService{
    @Autowired
    LoginMapper loginMapper;

    @Override
    public String doLogin(String username, Integer password) {
        //1.接收前端传过来的数据
        //2.先判断用户名是否存在
        User user = loginMapper.findByUserName(username);

        //3.如果存在判断密码是否正确
        if (user!=null){
            if (Integer.parseInt(user.getPassword()) == password){
                return "登录成功";
            }else {
                return "密码错误";
            }
        }else {
            return "用户名不存在";
        }
    }
}
